<?php

namespace app\admin\controller;

use app\admin\service\AdminService;
use app\BaseController;
use app\common\attributes\Menu;
use app\common\attributes\RandyValidate;
use app\common\validate\AdminValidate;
use think\annotation\route\Post;
use think\annotation\route\Resource;
use think\annotation\route\Validate;
use think\route\Rule;

class LoginController extends BaseController
{


    /**
     * @return \think\response\Json
     * @throws \Exception
     * @author : Randy_chen
     * @Date   : 2022/2/25
     * @Time   : 22:01
     */
    #[Menu('登录')]
    #[RandyValidate(AdminValidate::class, scene: 'login')]
    public function save()
    {
        $data = $this->getParams();
        $result = AdminService::loginAdminUser($data);
        return $this->returnSuccess($result);
    }

    /**
     * 忘记密码
     *
     * @author : Randy_chen
     * @Date   : 2022/2/18
     * @Time   : 22:31
     */
    #[Menu('设置密码')]
    #[RandyValidate(AdminValidate::class, scene: 'setPasswordByMobile')]
    public function setPasswordByMobile()
    {
        $params = $this->getParams();
        $result = AdminService::setPasswordByMobile($params);
        return $this->returnSuccess($result);
    }
}
